package org.ayachinene.leetcode.problems;

import java.util.Arrays;

import static java.lang.Math.*;

public class P1828 {
    static class Solution {
        public int[] countPoints(int[][] points, int[][] queries) {
            int[] result = new int[queries.length];
            //noinspection ForLoopReplaceableByForEach
            for (int i = 0; i < points.length; ++i) {
                for (int j = 0; j < queries.length; ++j) {
                    if (getDistancePow2(points[i], Arrays.copyOf(queries[j], 2)) <= pow(queries[j][2], 2)) {
                        result[j]++;
                    }
                }
            }
            return result;
        }

        private double getDistancePow2(int[] p1, int[] p2) {
            return pow(abs(p1[0] - p2[0]), 2) + pow(abs(p1[1]- p2[1]), 2);
        }
    }
}
